import request from '@/utils/request'

// 查询所有角色
export const getAllRoleAPI = () => {
  return request.get('/park/sys/role')
}

// 查询所有功能权限(树形)
export const getAllRoleTreeAPI = () => {
  return request.get('/park/sys/permision/all/tree')
}

/**
 * 获取当前角色权限点列表
 * @returns
 */
export function getRoleDetailAPI (roleId) {
  return request({
    url: `/park/sys/role/${roleId}`
  })
}

// 获取角色关联的用户列表
export const getUserListAPI = (roleId, params) => {
  return request.get(`/park/sys/roleUser/${roleId}`, { params })
}

// 创建角色
export function createRoleUserAPI (data) {
  return request({
    url: `/park/sys/role`,
    method: 'POST',
    data
  })
}

// 更改角色
export function updateRoleAPI (data) {
  return request({
    url: `/park/sys/role`,
    method: 'PUT',
    data
  })
}

/**
 * 删除角色
 * @returns
 */
export function delRoleUserAPI (roleId) {
  return request({
    url: `/park/sys/role/${roleId}`,
    method: 'DELETE'
  })
}
